/* Copyright (c) 2004-2008, Andriy Nikolov
 * All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.processmining.email;

import java.util.*;

/**
 * <p>A comparator for all objects, which implement TimeStampOwner interface. Is
 * used to sort such objects (messages, audit trail entries etc.) by date.
 *
 * @author Andriy Nikolov
 * @version 1.0
 */
public class TimestampOwnerComparator implements Comparator {

  public TimestampOwnerComparator() {
    try {
      jbInit();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  public int compare(Object o1, Object o2) throws ClassCastException {
    TimestampOwner to1, to2;
    to1 = (TimestampOwner)o1;
    to2 = (TimestampOwner)o2;
    if(to1.getTimestamp().before(to2.getTimestamp())) {
      return -1;
    }
    if(to1.getTimestamp().after(to2.getTimestamp())) {
      return 1;
    }
    return 0;
  }

  public boolean equals(Object obj) {
    return false;
  }

  private void jbInit() throws Exception {
  }
}
